
/*
 * vt220.c
 *
 * keytable of VT220 compatible key codes.
 *
 *
 * 21.07.2010, Klaus Hennemann
 */

#include <stdlib.h>
#include "../keytab.h"


/*--------------------------------------------------------------------------*/
/*	keycode table							    */
/*--------------------------------------------------------------------------*/

/*
 * directive	replacement
 *
 * %%		%
 * %e		escape on alt modifier
 * %m		bitwise combined modifiers
 * %r		RETURN/ENTER code (depends on LNM)
 *
 */
const struct Betty_KeyTab BETTY_KEYTAB_VT220 = {
	/* ANSI key codes */
	KEY_ANSI(	BETTY_KEY_UP,		"\033[A",	"\033[1;%mA" ),
	KEY_ANSI(	BETTY_KEY_DOWN,		"\033[B",	"\033[1;%mB" ),
	KEY_ANSI(	BETTY_KEY_RIGHT,	"\033[C",	"\033[1;%mC" ),
	KEY_ANSI(	BETTY_KEY_LEFT,		"\033[D",	"\033[1;%mD" ),
	KEY_ANSI(	BETTY_KEY_ESCAPE,	"\033",		"\033"	     ),
	KEY_ANSI(	BETTY_KEY_BACKSPACE,	"\x7f",		"\x7f"	     ),
	KEY_ANSI(	BETTY_KEY_TAB,		"\x09",		"\x09"	     ),
	KEY_ANSI(	BETTY_KEY_RETURN,	"%r",		"%r"	     ),
	KEY_ANSI(	BETTY_KEY_LINEFEED,	"\x0a",		"\x0a"	     ),
	KEY_ANSI(	BETTY_KEY_HOME,		"\033[1~",	"\033[1;%m~" ),
	KEY_ANSI(	BETTY_KEY_INSERT,	"\033[2~",	"\033[2;%m~" ),
	KEY_ANSI(	BETTY_KEY_DELETE,	"\033[3~",	"\033[3;%m~" ),
	KEY_ANSI(	BETTY_KEY_END,		"\033[4~",	"\033[4;%m~" ),
	KEY_ANSI(	BETTY_KEY_PAGEUP,	"\033[5~",	"\033[5;%m~" ),
	KEY_ANSI(	BETTY_KEY_PAGEDOWN,	"\033[6~",	"\033[6;%m~" ),
	KEY_ANSI(	BETTY_KEY_F1,		"\033OP",	"\033[1;%mP" ),
	KEY_ANSI(	BETTY_KEY_F2,		"\033OQ",	"\033[1;%mQ" ),
	KEY_ANSI(	BETTY_KEY_F3,		"\033OR",	"\033[1;%mR" ),
	KEY_ANSI(	BETTY_KEY_F4,		"\033OS",	"\033[1;%mS" ),
	KEY_ANSI(	BETTY_KEY_F5,		"\033[15~",	"\033[15;%m~"),
	KEY_ANSI(	BETTY_KEY_F6,		"\033[17~",	"\033[17;%m~"),
	KEY_ANSI(	BETTY_KEY_F7,		"\033[18~",	"\033[18;%m~"),
	KEY_ANSI(	BETTY_KEY_F8,		"\033[19~",	"\033[19;%m~"),
	KEY_ANSI(	BETTY_KEY_F9,		"\033[20~",	"\033[20;%m~"),
	KEY_ANSI(	BETTY_KEY_F10,		"\033[21~",	"\033[21;%m~"),
	KEY_ANSI(	BETTY_KEY_F11,		"\033[23~",	"\033[23;%m~"),
	KEY_ANSI(	BETTY_KEY_F12,		"\033[24~",	"\033[24;%m~"),
	KEY_ANSI(	BETTY_KEY_KP_MULTIPLY,	"*",		"*"	     ),
	KEY_ANSI(	BETTY_KEY_KP_ADD,	"+",		"+"	     ),
	KEY_ANSI(	BETTY_KEY_KP_COMMA,	",",		","	     ),
	KEY_ANSI(	BETTY_KEY_KP_MINUS,	"-",		"-"	     ),
	KEY_ANSI(	BETTY_KEY_KP_PERIOD,	".",		"."	     ),
	KEY_ANSI(	BETTY_KEY_KP_DIVIDE,	"/",		"/"	     ),
	KEY_ANSI(	BETTY_KEY_KP_0,		"0",		"0"	     ),
	KEY_ANSI(	BETTY_KEY_KP_1,		"1",		"1"	     ),
	KEY_ANSI(	BETTY_KEY_KP_2,		"2",		"2"	     ),
	KEY_ANSI(	BETTY_KEY_KP_3,		"3",		"3"	     ),
	KEY_ANSI(	BETTY_KEY_KP_4,		"4",		"4"	     ),
	KEY_ANSI(	BETTY_KEY_KP_5,		"5",		"5"	     ),
	KEY_ANSI(	BETTY_KEY_KP_6,		"6",		"6"	     ),
	KEY_ANSI(	BETTY_KEY_KP_7,		"7",		"7"	     ),
	KEY_ANSI(	BETTY_KEY_KP_8,		"8",		"8"	     ),
	KEY_ANSI(	BETTY_KEY_KP_9,		"9",		"9"	     ),
	KEY_ANSI(	BETTY_KEY_KP_EQUAL,	"=",		"="	     ),
	KEY_ANSI(	BETTY_KEY_KP_SPACE,	" ",		" "	     ),
	KEY_ANSI(	BETTY_KEY_KP_TAB,	"\x09",		"\x09"	     ),
	KEY_ANSI(	BETTY_KEY_KP_ENTER,	"%r",		"%r"	     ),

	/* DEC application keypad mode specific key codes */
	KEY_DECKPAM(	BETTY_KEY_KP_MULTIPLY,	"\033Oj",	NULL	     ),
	KEY_DECKPAM(	BETTY_KEY_KP_ADD,	"\033Ok",	NULL	     ),
	KEY_DECKPAM(	BETTY_KEY_KP_COMMA,	"\033Ol",	NULL	     ),
	KEY_DECKPAM(	BETTY_KEY_KP_MINUS,	"\033Om",	NULL	     ),
	KEY_DECKPAM(	BETTY_KEY_KP_PERIOD,	"\033On",	NULL	     ),
	KEY_DECKPAM(	BETTY_KEY_KP_DIVIDE,	"\033Oo",	NULL	     ),
	KEY_DECKPAM(	BETTY_KEY_KP_0,		"\033Op",	NULL	     ),
	KEY_DECKPAM(	BETTY_KEY_KP_1,		"\033Oq",	NULL	     ),
	KEY_DECKPAM(	BETTY_KEY_KP_2,		"\033Or",	NULL	     ),
	KEY_DECKPAM(	BETTY_KEY_KP_3,		"\033Os",	NULL	     ),
	KEY_DECKPAM(	BETTY_KEY_KP_4,		"\033Ot",	NULL	     ),
	KEY_DECKPAM(	BETTY_KEY_KP_5,		"\033Ou",	NULL	     ),
	KEY_DECKPAM(	BETTY_KEY_KP_6,		"\033Ov",	NULL	     ),
	KEY_DECKPAM(	BETTY_KEY_KP_7,		"\033Ow",	NULL	     ),
	KEY_DECKPAM(	BETTY_KEY_KP_8,		"\033Ox",	NULL	     ),
	KEY_DECKPAM(	BETTY_KEY_KP_9,		"\033Oy",	NULL	     ),
	KEY_DECKPAM(	BETTY_KEY_KP_EQUAL,	"\033OX",	NULL	     ),
	KEY_DECKPAM(	BETTY_KEY_KP_SPACE,	"\033O ",	NULL	     ),
	KEY_DECKPAM(	BETTY_KEY_KP_TAB,	"\033OI",	NULL	     ),
	KEY_DECKPAM(	BETTY_KEY_KP_ENTER,	"\033OM",	NULL	     ),
	
	/* DEC cursor key mode specific key codes */
	KEY_DECCKM(	BETTY_KEY_UP,		"\033OA",	"\033[1;%mA" ),
	KEY_DECCKM(	BETTY_KEY_DOWN,		"\033OB",	"\033[1;%mB" ),
	KEY_DECCKM(	BETTY_KEY_RIGHT,	"\033OC",	"\033[1;%mC" ),
	KEY_DECCKM(	BETTY_KEY_LEFT,		"\033OD",	"\033[1;%mD" )
};


